package demo;

/**
 * @Author liangbaigao
 * @Date 2023/9/24 23:02
 */
public class StaticInnerClass {

    private StaticInnerClass(){
        if(InnerClass.instance != null){
            throw new RuntimeException("不允许非法访问");
        }
    };

    private static class InnerClass{
        private static volatile StaticInnerClass instance
                = new StaticInnerClass();
    }

    public static StaticInnerClass getInstance(){
        return InnerClass.instance;
    }

}
